<?php 
class ModuleObject extends MasterObject
{
	function ModuleObject($config)
	{
		$this->MasterObject($config);
		$this->Execute();
	}

	
	function Execute()
	{
		switch($this->Code)
		{
			case 'modify':
				$this->Main();
				break;
			default:
				$this->Main();
				break;
		}
	}
	
	function Main()
	{
		$where = '';
		
		$order = '';
		
		$username = '';
		
		$query_link = "admin.php?mod=search";
		
		$user_list = array();
		
		$p = max((int)$this->Get['page'],1);
		
		$query_link .= "&page=".$p;
		
		$pn = (int)$this->Get['pn']?(int)$this->Get['pn']:20;
		
		if($pn<1)
			$pn=20;
		
		$query_link.='&pn='.$pn;
		
		$offset = ($p-1) * $pn;
		
		$username = trim($this->Get['username']);
		
		if ($username != "")
		{
			$where = " WHERE username like '%".$username."%'";
			$query_link.="&username=".urlencode($username);	
		}
		
		$sql = "SELECT count(1) as total FROM ".TABLE_PREFIX."system_members".$where;
		$query = $this->DatabaseHandler->Query($sql);
		$row = $query->GetRow();
		$total = $row['total'];
		
		$sql = "SELECT * FROM ".TABLE_PREFIX."system_members".$where." ".$order." limit $offset,$pn";
		
		$query = $this->DatabaseHandler->Query($sql);
		
		while ($row = $query->GetRow()) 
		{
			$user_list[] = $row;
		}
		
		$pages = page($total, $pn, $query_link, array(), "2 10 20 50 100 200 500");
		
		include $this->TemplateHandler->Template('admin/search');
	}
}